package com.vincent.datasourcedriud;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author vincent
 * @date 2019/4/21
 * @description
 */
@Component
public class Bootstrap implements CommandLineRunner {
    private static final Logger LOGGER = LoggerFactory.getLogger(Bootstrap.class);
    @Resource
    private JdbcTemplate jdbcTemplate;
    @Override
    public void run(String... args) throws Exception {
        long start = System.currentTimeMillis();
        jdbcTemplate.queryForList("SELECT * FROM userinfo").forEach(row -> LOGGER.info(row.toString()));
        long end = System.currentTimeMillis();
        LOGGER.info("cost {} ms", (end -start));

    }
}
